//captcha check //needs getUrlParam plugin
function formCaptchaCheck(){
	if($("#captcha").length>0){
		var param1 = $(document).getUrlParam("RadUrid");
		if (param1 != null){alert("Captcha code incorrect at bottom of form, please try again.");
		$("#captcha input").css("background", "#fcc").select();
	}}
}

//Remove line breaks in file upload fields and other places
function formBrCleanup(){
	$("#ctl00_ContentPlaceHolder1_panelFileUpload br").remove();
	$(".formTable br").remove();
}

/* -------------------------------------------- */
/* ***********  FORM VALIDATION  ************* */
$(document).ready(function() {
if ($("#customform").length){
	jQuery.validator.messages.required = "";
    $("#aspnetForm").validate({
    
    errorElement: "span",
    invalidHandler: function(form, validator) {
      var errors = validator.numberOfInvalids();
      if (errors) {
        var message = errors == 1
          ? 'The highlighted field is required.'
          : 'The ' + errors + ' highlighted fields are required.';
        $("div#summary span").html(message);
        $("div#summary").show();
      } else {
        $("div#summary").hide();
      }
    },

    validClass: "valid",
    rules: { _emailMe_Email: {email: true} },
	messages: { _emailMe_Email: { 
			required: " ",
			email: "Please enter a valid email address<br/>(example: you@yourdomain.com)"
			} }
    });//eof validate
	$("#phone").mask("(999) 999-9999");
	$("#fax").mask("(999) 999-9999");
	}//eof #customform.length

if ($("body").hasClass("createAccount")){

	jQuery.validator.messages.required = "";
	$("#createAccount_accountInfoTable").prepend("<div id='summary'><span>&nbsp;</span></div>");
    $("#aspnetForm").validate({
    invalidHandler: function(form, validator) {
      var errors = validator.numberOfInvalids();
      if (errors) {
        var message = errors == 1
          ? 'The highlighted field is required.'
          : 'The ' + errors + ' highlighted fields are required.';
        $("div#summary span").html(message);
        $("div#summary").show();
      } else {
        $("div#summary").hide();
      }
    },

    validClass: "valid",
    rules: { 
    	ctl00$ContentPlaceHolder1$txtEmail: {required: true, email: true},
    	ctl00$ContentPlaceHolder1$txtFirstName: "required",
    	ctl00$ContentPlaceHolder1$txtLastName: "required",
    	ctl00$ContentPlaceHolder1$txtAddress1: "required",
    	ctl00$ContentPlaceHolder1$txtCity: "required",
    	ctl00$ContentPlaceHolder1$txtPostal: "required",
    	ctl00$ContentPlaceHolder1$txtPhone: "required",
    	ctl00$ContentPlaceHolder1$txtPassword1: "required",
    	ctl00$ContentPlaceHolder1$txtPassword2: {equalTo: "#ctl00_ContentPlaceHolder1_txtPassword1"}
    },
	messages: {
		ctl00$ContentPlaceHolder1$txtPassword2: {
				required: " ",
				equalTo: "Passwords don't match"	
		},

		ctl00$ContentPlaceHolder1$txtEmail: { 
			required: " ",
			email: "Email Invalid"
		} 
	}
    });//eof validate
	$("#ctl00_ContentPlaceHolder1_txtPhone").mask("(999) 999-9999");
	$("#ctl00_ContentPlaceHolder1_txtFax").mask("(999) 999-9999");
	}//eof #hasClass



if ($("body").hasClass("profile")){

	jQuery.validator.messages.required = "";
	$("#ctl00_ContentPlaceHolder1_profile_accountInfoTable").prepend("<div id='summary'><span>&nbsp;</span></div>");
    $("#aspnetForm").validate({
    invalidHandler: function(form, validator) {
      var errors = validator.numberOfInvalids();
      if (errors) {
        var message = errors == 1
          ? 'The highlighted field is required.'
          : 'The ' + errors + ' highlighted fields are required.';
        $("div#summary span").html(message);
        $("div#summary").show();
      } else {
        $("div#summary").hide();
      }
    },

    validClass: "valid",
    rules: { 
    	ctl00$ContentPlaceHolder1$txtEmail: {required: true, email: true},
    	ctl00$ContentPlaceHolder1$txtFirstName: "required",
    	ctl00$ContentPlaceHolder1$txtLastName: "required",
    	ctl00$ContentPlaceHolder1$txtAddress1: "required",
    	ctl00$ContentPlaceHolder1$txtCity: "required",
    	ctl00$ContentPlaceHolder1$txtPostal: "required",
    	ctl00$ContentPlaceHolder1$txtPhone: "required",
    	ctl00$ContentPlaceHolder1$txtPassword1: "required",
    	ctl00$ContentPlaceHolder1$txtPassword2: {equalTo: "#ctl00_ContentPlaceHolder1_txtPassword1"}
    },
	messages: {
		ctl00$ContentPlaceHolder1$txtPassword2: {
				required: " ",
				equalTo: "Passwords don't match"	
		},

		ctl00$ContentPlaceHolder1$txtEmail: { 
			required: " ",
			email: "Email Invalid"
		} 
	}
    });//eof validate
	$("#ctl00_ContentPlaceHolder1_txtPhone").mask("(999) 999-9999");
	$("#ctl00_ContentPlaceHolder1_txtFax").mask("(999) 999-9999");
	}//eof #hasClass

	
	if ($("body").hasClass("storeForm")){ 
	jQuery.validator.messages.required = "";
	$(".formTable").before("<div id='summary'><span>&nbsp;</span></div>");
    $("#aspnetForm").validate({
    invalidHandler: function(form, validator) {
      var errors = validator.numberOfInvalids();
      if (errors) {
        var message = errors == 1
          ? 'The highlighted field is required.'
          : 'The ' + errors + ' highlighted fields are required.';
        $("div#summary span").html(message);
        $("div#summary").show();
      } else {
        $("div#summary").hide();
      }
    },

    validClass: "valid",
    rules: { 
    	ctl00$ContentPlaceHolder1$txtContactEmail: {required: true, email: true},
    	ctl00$ContentPlaceHolder1$txtContactName: "required",
    	ctl00$ContentPlaceHolder1$txtCompany: "required",
    	ctl00$ContentPlaceHolder1$txtContactPhone: "required",
    	ctl00$ContentPlaceHolder1$CaptchaControl1: "required"
    },
	messages: {
		ctl00$ContentPlaceHolder1$txtContactEmail: { 
			required: " ",
			email: "Email Invalid"
		} 
	}
    });//eof validate
	$("#ctl00_ContentPlaceHolder1_txtContactPhone").mask("(999) 999-9999");
	$("#ctl00_ContentPlaceHolder1_txtContactFax").mask("(999) 999-9999");
	}//eof #hasClass
	
	
});//eof .ready
//---->>


